import cv2
image=cv2.imread('hat.png',cv2.IMREAD_GRAYSCALE)
cv2.imshow("Input",image)
kernel=cv2.getStructuringElement(cv2.MORPH_RECT,(3,3))
image1=cv2.erode(image,kernel)
image2=cv2.dilate(image,kernel)
cv2.imshow('Output',image2)
cv2.waitKey()
cv2.destroyWindow()